Shader "dissolve" {

Properties
{
    _Albedo ("Albedo", 2D) = "white" {}
    _DissolveTex ("DissolveTex", 2D) = "white" {}
	_EdgeColor ("edgeColor", Color) = (0, 0.55, 0.8, 1)
	_LineWidth("LineWidth", Range(0,0.5)) = 2
	_DissolveAmount("DissolveAmount", Range(0,1)) = 0.1
}
SubShader
{
    Tags {}

CGPROGRAM

#pragma surface surf Standard 

sampler2D _Albedo;
sampler2D _DissolveTex;

fixed4 _EdgeColor;
float _LineWidth;
float _DissolveAmount;

struct Input 
{
    float2 uv_Albedo;
    float2 uv_DissolveTex;
};

void surf (Input IN, inout SurfaceOutputStandard o) 
{
    float dissolve = tex2D(_DissolveTex, IN.uv_DissolveTex).r;
	
    clip( dissolve - _DissolveAmount);

    if ( dissolve > _DissolveAmount + _LineWidth)
        o.Albedo =  tex2D(_Albedo, IN.uv_Albedo);
    else
        o.Albedo = _EdgeColor;
}

ENDCG
}
    FallBack "Diffuse"
}
